﻿#include "example.h"
#include <thread>
#include <iostream>

void printLog()
{
	for (int i = 0; i < 10; i++)
	{
		auto pid = std::this_thread::get_id();
		LogWarn << "pid = " << pid << ", range" << i << std::endl;
		std::this_thread::sleep_for(std::chrono::seconds(1));
	}
}

int main()
{
	mylog::SLoggerSample::instance().init("thread_test");

	//LogWarn << "hello" << std::endl;
	//getchar();
	//return 0;

	std::cout << "create 5 threads" << std::endl;
	std::thread threads[5];
	for (int i = 0; i < 5; i++)
	{
		threads[i] = std::thread(printLog);
	}

	std::cout << "wait for them..." << std::endl;
	for (auto& t : threads)
	{
		t.join();
	}
	std::cout << "done" << std::endl;
	getchar();
	return 0;
}